package com.heiye.blog.ai.factory;

import com.google.common.collect.Maps;
import com.heiye.blog.ai.enums.RoleNameEnum;
import com.heiye.blog.ai.enums.SoundModelTypeEnum;
import com.heiye.blog.ai.strategy.role.RoleStrategy;
import com.heiye.blog.ai.strategy.sound.SoundModelStrategy;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;

/**
 * @author: heiye
 * @date: 2025/11/19 下午10:05
 * @version: v1.0.0
 * @description: 语音模型策略工厂
 */
@Configuration
public class SoundModelStrategyFactory {
    /**
     * 该处存放所有文本模型策略 --- 自动装配
     */
    @Resource
    private List<SoundModelStrategy> soundModelStrategies;

    private final Map<SoundModelTypeEnum, SoundModelStrategy> soundModelStrategyMap = Maps.newHashMap();

    /**
     * @PostConstruct： 构造方法执行完成之后执行将 textModelStrategyMap 填充
     */
    @PostConstruct
    public void init() {
        soundModelStrategies.forEach(soundModelStrategy ->
                soundModelStrategyMap.put(soundModelStrategy.getSoundModelTypeEnum(), soundModelStrategy));
    }

    public SoundModelStrategy getStrategy(String name, String version) {
        SoundModelTypeEnum soundModelTypeEnum = SoundModelTypeEnum.getSoundModelTypeEnum(name, version);
        return soundModelStrategyMap.get(soundModelTypeEnum);
    }
}
